
// Core Entities based on PRD

export enum TaskType {
  HARMONY_API = 'HARMONY_API',
  ARKTS_CONSISTENCY = 'ARKTS_CONSISTENCY',
  CJD_SOURCE = 'CJD_SOURCE',
}

export enum IssueSeverity {
  CRITICAL = 'Critical',
  WARNING = 'Warning',
  INFO = 'Info',
}

export enum ScanStatus {
  PENDING = 'Pending',
  RUNNING = 'Running',
  COMPLETED = 'Completed',
  FAILED = 'Failed',
}

export enum ConfirmationStatus {
  UNCONFIRMED = 'Unconfirmed',
  CONFIRMED = 'Confirmed',
}

export enum ConfirmationType {
  REAL_ISSUE = 'Real Issue',
  FALSE_POSITIVE = 'False Positive',
  FIXED = 'Fixed',
  KNOWN_ISSUE = 'Known Issue',
  NONE = 'None'
}

// Dynamic Field Configuration
export interface FieldConfig {
  key: string;
  label: string;
  type: 'text' | 'number' | 'date' | 'code' | 'boolean';
  isFilterable?: boolean;
}

// Task Definition
export interface ScanTask {
  id: string;
  type: TaskType;
  name: string;
  description: string;
  lastScanTime?: string;
  // Configuration for dynamic fields specific to this task type
  recordFields: FieldConfig[];
  issueFields: FieldConfig[];
}

// A Single Execution Record
export interface ScanRecord {
  id: string;
  taskId: string;
  branch: string;
  startTime: string;
  duration: string; // e.g., "45s"
  creator?: string; // Added creator
  status: ScanStatus;
  totalIssues: number;
  confirmedIssues: number;
  unconfirmedIssues: number;
  // Dynamic fields key-value pairs
  extensionData?: Record<string, any>;
}

export interface ConfirmationHistoryItem {
  id: string;
  timestamp: string;
  actor: string;
  type: ConfirmationType;
  note?: string;
  action: 'create' | 'update' | 'revoke';
}

// A Specific Issue Found
export interface ScanIssue {
  id: string;
  recordId: string;
  ruleName: string;
  severity: IssueSeverity;
  filePath: string;
  lineNumber: number;
  description: string;
  codeSnippet?: string;
  
  // Confirmation Logic
  confirmationStatus: ConfirmationStatus;
  confirmationType: ConfirmationType;
  confirmationNote?: string;
  confirmedBy?: string;
  confirmedAt?: string;

  // History Trail
  history: ConfirmationHistoryItem[];
  
  // Inheritance Logic
  inheritedFromRecordId?: string; // If inherited from a previous scan
  
  // Dynamic fields
  extensionData?: Record<string, any>;
}
